package mc

import (
	"gitee.com/dreamwood/ez-go/db/mgo"
)

const (
	BuyerEventNew           = "erp.BuyerNew"
	BuyerEventBeforeCreate  = "erp.BuyerBeforeCreate"
	BuyerEventBeforeUpdate  = "erp.BuyerBeforeUpdate"
	BuyerEventBeforeSave    = "erp.BuyerBeforeCreate erp.BuyerBeforeUpdate"
	BuyerEventAfterCreate   = "erp.BuyerAfterCreate"
	BuyerEventAfterUpdate   = "erp.BuyerAfterUpdate"
	BuyerEventAfterSave     = "erp.BuyerAfterCreate erp.BuyerAfterUpdate"
	BuyerEventDelete        = "erp.BuyerDelete"
	BuyerAccessControlEvent = "erp.BuyerAccessControl"
)

func GetBuyerConfig() *mgo.DocConfig {
	return Buyer_Config
}

var Buyer_Config *mgo.DocConfig

func init() {
	Buyer_Config = NewBuyerConfig()
}
func NewBuyerConfig() *mgo.DocConfig {
	return &mgo.DocConfig{
		ContainerKey: "erp.Buyer",
		Fields: []string{
			"name", "fastName", "cat", "level", "isOn",
		},
		RelationFields: []string{
			"cat", "level",
		},
		RelationConfigs: map[string]*mgo.DocRelation{
			"cat": {
				Config:     GetBuyerCategoryConfig,
				DocName:    "BuyerCategory",
				JoinType:   "O",
				KeyInside:  "catId",
				KeyOutSide: "id",
			},
			"level": {
				Config:     GetBuyerLevelConfig,
				DocName:    "BuyerLevel",
				JoinType:   "O",
				KeyInside:  "levelId",
				KeyOutSide: "id",
			},
		},
		FieldFilter: map[string]*mgo.DocFieldFilter{
			"default": {
				Select: []string{},
				Omit:   []string{},
			},
		},
	}
}
